
#ifndef ZHOUBIAN_UI_LOGIC_H
#define ZHOUBIAN_UI_LOGIC_H

#include <QGridLayout>
#include <QWidget>
#include "Product.h"
#include "ZhouBian_ui.h"
#include "globals.h"
#include <QPushButton>
#include <QLabel>

class productgridwidget : public QWidget
{
    Q_OBJECT
public:
    explicit productgridwidget(QWidget *parent = nullptr);
    void setEventData(const QPixmap &image,
                      const QString &title,
                      const QString &price,
                      const QString &description,
                      int productId,
                      int index);
    void populateProductWidgets();
    ~productgridwidget();

private:
    QVBoxLayout *gridLayout;
    QVBoxLayout *productListLayout;
    QHBoxLayout *paginationLayout;    // 分页栏布局
    QList<ProductWidget *> *eventWidgets;


    int currentPage = 0;
    const int itemsPerPage = 6;

    void updatePage();
    void updatePagination();
private slots:
    void showProductDetail(const QPixmap &image, const QString &title,
                      const QString &description,
                      const QString &price, int productId);
    /*void handleBuyButtonClicked(const QString &productName,
                                const QString &productPrice,
                                int productId); // 添加处理按钮点击的槽函数*/
    void goToNextPage();
    void goToPreviousPage();
};

#endif // ZHOUBIAN_UI_LOGIC_H
